part of 'articles_bloc.dart';

// ArticlesUninitialized, ArticlesLoading ArticlesLoaded ArticlesError

enum FeedType {
  globalFeed,
  userFeed,
}

sealed class ArticlesState extends Equatable {
  const ArticlesState();
  
  @override
  List<Object> get props => [];
}

final class ArticlesInitial extends ArticlesState {}

final class ArticlesUninitialized extends ArticlesState {}

final class ArticlesLoading extends ArticlesState {}

class ArticlesLoaded extends ArticlesState {
  final FeedType feedType;
  final List<Article> articles;
  final bool hasReachedMax;

  const ArticlesLoaded({
     required this.feedType,
     required this.articles,
     required this.hasReachedMax
  });

  ArticlesLoaded copyWith({
    FeedType? feedType,
    List<Article>? articles,
    bool? hasReachedMax,
  }) {
    return ArticlesLoaded(
      feedType: feedType ?? this.feedType,
      articles: articles ?? this.articles,
      hasReachedMax: hasReachedMax ?? this.hasReachedMax,
    );
  }

  @override
  List<Object> get props => [feedType, articles, hasReachedMax];
}

class ArticlesError extends ArticlesState {
  final Object error;

  const ArticlesError({
    required this.error,
  });

  @override
  List<Object> get props => [error];
}